﻿@model CustomerModel
@inject AdminAreaSettings adminAreaSettings
@{
<div class="panel panel-default">
    <vc:admin-widget widget-zone="customer_details_orders_top" additional-data="Model" />
    <div class="panel-body">
        <div id="order-grid"></div>
    </div>
    <vc:admin-widget widget-zone="customer_details_orders_bottom" additional-data="Model" />
</div>
    <script>
        $(document).ready(function () {
            $("#order-grid").kendoGrid({
                dataSource: {
                    transport: {
                        read: {
                            url: "@Html.Raw(Url.Action("OrderList", "Customer", new { customerId = Model.Id }))",
                            type: "POST",
                            dataType: "json",
                            data: addAntiForgeryToken
                        }
                    },
                    schema: {
                        data: "Data",
                        total: "Total",
                        errors: "Errors"
                    },
                    error: function(e) {
                        display_kendoui_grid_error(e);
                        // Cancel the changes
                        this.cancelChanges();
                    },
                    pageSize: @(adminAreaSettings.DefaultGridPageSize),
                    serverPaging: true,
                    serverFiltering: true,
                    serverSorting: true
                },
                pageable: {
                    refresh: true,
                    pageSizes: [@(adminAreaSettings.GridPageSizes)]
                },
                editable: {
                    confirmation: false,
                    mode: "inline"
                },
                scrollable: false,
                columns: [{
                    field: "OrderNumber",
                    title: "@T("Admin.Customers.Customers.Orders.ID")",
                    width: 90,
                    template: '<a class="k-link" href="@Url.Content("~/Admin/Order/Edit/")#=Id#">#=OrderNumber#</a>'
                }, {
                    field: "OrderTotal",
                    title: "@T("Admin.Customers.Customers.Orders.OrderTotal")",
                    width: 120,
                    template: '<a class="k-link" href="@Url.Content("~/Admin/Order/Edit/")#=Id#">#=OrderTotal#</a>'
                }, {
                    field: "OrderStatus",
                    title: "@T("Admin.Customers.Customers.Orders.OrderStatus")",
                    width: 160
                }, {
                    field: "PaymentStatus",
                    title: "@T("Admin.Customers.Customers.Orders.PaymentStatus")",
                    width: 180
                }, {
                    field: "ShippingStatus",
                    title: "@T("Admin.Customers.Customers.Orders.ShippingStatus")",
                    width: 180
                }, {
                    field: "StoreName",
                    title: "@T("Admin.Customers.Customers.Orders.Store")",
                    width: 200
                }, {
                    field: "CreatedOn",
                    title: "@T("Admin.System.Log.Fields.CreatedOn")",
                    width: 220,
                    type: "date",
                    format: "{0:G}"
                }]
            });
        });
    </script>
}